import api from "@/utils/api.js";

export const getUserInfo = async () => {
  let userInfo = uni.getStorageSync("userInfo");
  if (!userInfo) {
    try {
      const res = await api.myInfo();
      setUserInfo(res.data);
      userInfo = res.data;
    } catch (error) {
      console.log(error);
    }
  }

  return userInfo;
};

export const setUserInfo = (userInfo) => {
  uni.setStorageSync("userInfo", userInfo);
};
